<?php

namespace yiike\finance\models;

use Yii;
use \yiike\finance\models\base\TokerWithdraw as BaseTokerWithdraw;
use yii\helpers\ArrayHelper;

/**
 * This is the model class for table "ims_ttyc_combo_allot".
 */
class TokerWithdraw extends BaseTokerWithdraw
{
    public $status_option = ['' => '', 0 => '审核中', 1 => '审核通过', 2 => '拒绝', 3 => '异常处理'];
    public $type_option = ['' => '', 1 => '微信', 2 => '支付宝', 3 => '银行卡'];
    public $pay_option = ['' => '', 0 => '等待打款', 1 => '打款完成'];

    public function behaviors()
    {
        return ArrayHelper::merge(
            parent::behaviors(),
            [
                # custom behaviors
            ]
        );
    }

    public function rules()
    {
        return ArrayHelper::merge(
            parent::rules(),
            [
                # custom validation rules
            ]
        );
    }

    public function attributeLabels()
    {
        return array_merge(parent::attributeLabels(), [
            'toker_id' => '推手',
            'status' => '状态',
            'type' => '提现方式',
        ]);
    }

    public function beforeSave($insert)
    {
        if ($this->status != $this->oldAttributes['status']) {
            $this->check_by = Yii::$app->user->id;
            $this->check_at = time();
        }

        if ($this->pay_sn != $this->oldAttributes['pay_sn']) {
            $this->pay_by = Yii::$app->user->id;
            $this->pay_at = time();
        }
        return parent::beforeSave($insert); // TODO: Change the autogenerated stub
    }
}
